import json
import requests
import time

url = 'https://www.kuaidi100.com/query'
com = ['zhongtong', 'zhaijisong', 'yunda', 'yuantong', 'youzhengguoji', 'youshuwuliu', 'youzhengguonei',
       'youshuwuliu', 'wxwl', 'sue', 'shentong', 'guotongkuaidi', 'huitongkuaidi']
nu = ['75357756098496', 'YT4564249477302', '773039645953853', '557010281000238', 'YT4562967819835', '75358285881311',
      '611162624920369', '611162624920793', '611162624920581', '611162624920637', '4305967699662', '75358381728512',
      'YT4567435390940', '557010283371843', '75358335050863', '4306019156630', 'YT4568173695528', 'YT4567421454366',
      '557010269167082', '9862294338516', '552010966544705', '78132663937338']

for c in com:
    for n in nu:
        data = {
            'type': c,
            'postid': n
        }
        response = requests.get(url, params=data)
        result = response.json()
        # print(json.dumps(result, ensure_ascii=False, indent=4, sort_keys=False))
        timeArray = time.strptime(result['data'][0]['time'], '%Y-%m-%d %H:%M:%S')
        if time.mktime(timeArray) < 1590985707 or result['data'][0]['context'] == '查无结果':
            continue
        else:
            print(result['nu'], result['com'], result['data'][0]['time'], result['data'][0]['context'])
    time.sleep(5)
